package com.jkoss.biz.imp.kc;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.jkoss.biz.kc.HomeworkBiz;
import com.jkoss.dao.kc.HomeworkMapper;
import com.jkoss.pojo.kc.Homework;
import com.jkoss.tool.Page;
@Component
public class HomeworkBizImpl  implements HomeworkBiz {
    
	@Autowired
	private  HomeworkMapper hwDao;
    
	//查询全部
	@Override
	public List<Homework> listPageHw(Page<Homework> page,Integer sbid) {
		
		if(sbid==null||sbid==0){
		 return hwDao.selectByPageAndEid(page);	
		}
		
		Map<String, Object> params = new HashMap<String, Object>();
    	params.put("sbid", sbid);
    	page.setParams(params);
		return hwDao.findHwBySbid(page);
	}
    
	//单个查看
	@Override
	public Homework findById(int hkid) {
		
		return hwDao.selectById(hkid);
	}
    
	//删除单个
	@Override
	@Transactional
	public String delHw(int hkid) {
		
		return hwDao.deleteByPrimaryKey(hkid)>0?"删除成功":"删除失败";
	}
    //增加
	@Override
	@Transactional
	public String addHw(Homework homework) {
		
		return hwDao.insert(homework)>0?"添加成功":"添加失败";
	}
    
	//修改
	@Override
	@Transactional
	public String updHw(Homework hw) {
		
		return hwDao.updateByPrimaryKey(hw)>0?"修改成功":"修改失败";
	}

	@Override
	public List<Homework> findHwBySbid(Page<Homework> page) {
		
		return hwDao.findHwBySbid(page);
	}
    
	
	
	
	
	

}
